package com.itcase.JDBC_01.JDBCDome;

import java.sql.*;

public class JDBCText {
    public static void main(String[] args) {
        //导包
        //注册驱动
        try {
            Class.forName("com.mysql.jdbc.Driver");
            //获取链接
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db2","root","root");
            //获取执行者对象
            Statement stat = con.createStatement();
            //执行sql语句,并接收
            String s = "SELECT * FROM USER";
            ResultSet res = stat.executeQuery(s);
            while (res.next()){
                System.out.println(res.getInt("id")+res.getString("name")+res.getInt("age"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
